<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>文件上传</title>
    <script src="./js/jquery-3.6.0.js"></script>
    <style>
      #video{
        width: 500px;
        height: 400px;
      }
    </style>
  </head>
  <body>
    <h1>文件上传</h1>
    <form action="/upload" method="post" enctype="multipart/form-data">
      <input id="files" type="file" name="file" multiple />
      <!-- 这里的multiple属性是允许多文件上传的,一点要写-->
      <input type="submit" value="上传" />
    </form>
    <video id="video" controls></video>
    <script src="http://bilibili.github.io/flv.js/dist/flv.js"></script>
    <script>
      let video=document.getElementById('video')
      if (flvjs.isSupported()) {
        var flvPlayer = flvjs.createPlayer({
          type: "flv",
          url: 'http://192.168.0.12:19968/live/app1.flv',
        });
        flvPlayer.attachMediaElement(video);
        flvPlayer.load();
        flvPlayer.play();
      }

        // 浏览器标签栏切换事件
      document.addEventListener('visibilitychange',()=>{
        console.log('切换了')
      })

      let n=0;
      let time=null;
      // 浏览器获得焦点事件
      window.onfocus=()=>{
        console.log(`离开时间${n}秒`)
        clearInterval(time)
      }
       // 浏览器失去焦点事件
      window.onblur=()=>{
       time= setInterval(()=>{
          n++;
        },1000)
      }
    </script>
  </body>
</html>
